# import openpyxl
# import requests
# from datetime import datetime
#
#
# def read_data_from_excel(excel_path):
#     # 打开 Excel 工作簿
#     workbook = openpyxl.load_workbook(excel_path)
#
#     # 选择活动工作表（或指定工作表名称）
#     sheet = workbook.active  # 或者使用 workbook['SheetName'] 指定工作表
#
#     # 读取数据
#     data = []
#     for row in sheet.iter_rows(values_only=True):
#         data.append(row)
#
#     return data
#
#
# start_time = datetime.now()
# # 示例 Excel 文件路径
# excel_path = 'text1.xlsx'
#
# # 从 Excel 文件中读取数据
# data = read_data_from_excel(excel_path)
#
# # 写入一个新的Excel
# wb = openpyxl.Workbook()
# ws = wb.active
# new_data = [['单词', '音标', '翻译']]
#
# # 打印读取的数据
# for row in data:
#     # 判断是否为一个单词
#     if row[0].isalpha():
#         try:
#             response = requests.get(f'https://api.dictionaryapi.dev/api/v2/entries/en/{row[0]}')
#             new_data.extend([[row[0], response.json()[0]['phonetics'][0]['text'], row[2]]])
#         except Exception as e:
#             print(e)
#             continue
#         print(f'{row[0]}：音标获取成功')
#
# for phonetics in new_data:
#     ws.append(phonetics)
#
# wb.save('phonetics.xlsx')
# end_time = datetime.now()
#
# execution_time = (end_time - start_time).total_seconds()
# print(f"程序运行时间: {execution_time} 秒")
# """
# [{'word': 'after', 'phonetic': '/ˈæf.tə(ɹ)/', 'phonetics': [{'text': '/ˈæf.tə(ɹ)/', 'audio': ''}, {'text': '/ˈæf.tɚ/', 'audio': 'https://api.dictionaryapi.dev/media/pronunciations/en/after-us.mp3', 'sourceUrl': 'https://commons.wikimedia.org/w/index.php?curid=191972', 'license': {'name': 'BY-SA 3.0', 'url': 'https://creativecommons.org/licenses/by-sa/3.0'}}], 'meanings': [{'partOfSpeech': 'adjective', 'definitions': [{'definition': 'Later; second (of two); next, following, subsequent', 'synonyms': [], 'antonyms': []}, {'definition': '(where the frame of reference is within the ship) At or towards the stern of a ship.', 'synonyms': [], 'antonyms': [], 'example': 'The after gun is abaft the forward gun.'}], 'synonyms': [], 'antonyms': []}, {'partOfSpeech': 'adverb', 'definitions': [{'definition': 'Behind; later in time; following.', 'synonyms': [], 'antonyms': [], 'example': 'I left the room, and the dog bounded after.'}], 'synonyms': [], 'antonyms': []}, {'partOfSpeech': 'preposition', 'definitions': [{'definition': 'Subsequently to; following in time; later than.', 'synonyms': [], 'antonyms': [], 'example': 'The Cold War began shortly after the Second World War.'}, {'definition': 'Behind.', 'synonyms': [], 'antonyms': [], 'example': 'He will leave a trail of destruction after him.'}, {'definition': 'In pursuit of, seeking.', 'synonyms': [], 'antonyms': [], 'example': "He's after a job; run after him; inquire after her health."}, {'definition': 'In allusion to, in imitation of; following or referencing.', 'synonyms': [], 'antonyms': [], 'example': 'We named him after his grandfather; a painting after Leonardo da Vinci.'}, {'definition': 'Next in importance or rank.', 'synonyms': [], 'antonyms': [], 'example': 'The princess is next in line to the throne after the prince.'}, {'definition': 'As a result of.', 'synonyms': [], 'antonyms': [], 'example': 'After your bad behaviour, you will be punished.'}, {'definition': 'In spite of.', 'synonyms': [], 'antonyms': [], 'example': 'After all that has happened, he is still my friend.'}, {'definition': '(usually preceded by a form of be, followed by an -ing form of a verb) Used to indicate recent completion of an activity', 'synonyms': [], 'antonyms': [], 'example': 'I was after finishing my dinner when there was a knock on the door.'}, {'definition': 'According to an author or text.', 'synonyms': [], 'antonyms': []}, {'definition': 'Denoting the aim or object; concerning; in relation to.', 'synonyms': [], 'antonyms': [], 'example': 'to look after workmen; to enquire after a friend; to thirst after righteousness'}, {'definition': 'According to the direction and influence of; in proportion to; befitting.', 'synonyms': [], 'antonyms': []}], 'synonyms': ['post'], 'antonyms': []}, {'partOfSpeech': 'conjunction', 'definitions': [{'definition': 'Signifies that the action of the clause it starts takes place before the action of the other clause.', 'synonyms': [], 'antonyms': [], 'example': 'I went home after we had decided to call it a day.'}], 'synonyms': [], 'antonyms': []}], 'license': {'name': 'CC BY-SA 3.0', 'url': 'https://creativecommons.org/licenses/by-sa/3.0'}, 'sourceUrls': ['https://en.wiktionary.org/wiki/after']}]
#
# [['单词', '音标', '翻译'], ['after', '/ˈæf.tə(ɹ)/', 'prep在...之后'], ['afternoon', '/af.təɾˈnʉːn/', 'n下午'], ['picture', '/ˈpɪktʃə/', 'v/n描绘，图片'], ['photograph', '/ˈfəʊ.tə.ˌɡɹɑːf/', 'v/n照相，拍照，照片'], ['photography', '/fəˈtɒɡɹəfi/', 'n摄影'], ['photographer', '/fəˈtɒɡɹəfə/', 'n摄影师'], ['gain', '/ɡeɪn/', 'v/n获得，赢得，好处，收益'], ['again', '/əˈɡeɪn/', 'ad再次，又'], ['against', '/əˈɡeɪnst/', 'prep反对，违背'], ['regain', '/ɹiːˈɡeɪn/', 'v/n重新获得，恢复；重回，回到（某处）'], ['mind', '/maɪnd/', 'v/n苦恼，介意，大脑，心智，注意力'], ['remind', '/ɹəˈmaɪnd/', 'v提醒，使想起'], ['final', '/ˈfaɪ.nəl/', 'a/n最终的，决定性的，决赛'], ['finally', '/ˈfaɪ.nəl.i/', 'ad终于，最后，最终'], ['day', '/deɪ/', 'n天，日子'], ['birth', '/bɜːθ/', 'v/n出身，诞生'], ['birthday', '/ˈbɜːθ.deɪ/', 'n生日'], ['nowadays', '/ˈnaʊ.ə.deɪz/', 'ad如今，现在'], ['arrive', '/əˈɹaɪv/', 'v达到，抵达，送达'], ['arrival', '/əˈɹaɪ.vəl/', 'n到达，到来，出现'], ['senior', '/ˈsiːnjə(r)/', 'a/n年长的，长辈（的），高级的，上级'], ['wake', '/ˈweɪk/', 'v唤醒，醒来，激发'], ['early', '/ˈɜː.li/', 'a/ad早的，早起的/地'], ['earth', '/ɜːθ/', 'n地球，泥土'], ['earthquake', '/ˈɜːθkweɪk/', 'n地震'], ['quake', '/kweɪk/', 'v震动'], ['rush', '/ɹʌʃ/', 'v/n冲，奔，催促，仓促做'], ['door', '/dɔː/', 'n门，门口，门户'], ['doormat', '/ˈdɔː(ɹ)ˌmæt/', 'n门垫，受气包'], ['eager', '/ˈiːɡə/', 'a渴望的,渴求的,热切的'], ['eagle', '/ˈiːɡəl/', 'n老鹰'], ['eagerness', '/ˈiːɡənəs/', 'n渴望，热心'], ['new', '/njʉː/', 'a新的，崭新的  n新事物'], ['news', '/njuːz/', 'n新闻'], ['newspaper', '/ˈnjuːsˌpeɪpə/', 'n报纸'], ['study', '/ˈstʌdi/', 'v/n学习，研究'], ['student', '/ˈstjuː.dənt/', 'n学生，学者'], ['scholar', '/ˈskɒlə/', 'n学者，有学问的人'], ['campus', '/ˈkæmpəs/', 'n校园，大学生活'], ['quite', '/kwaɪt/', 'ad相当,很'], ['quiet', '/ˈkwaɪ.ət/', 'a安静的，平静的，寂静的'], ['decide', '/dɪˈsaɪd/', 'v决定'], ['decision', '/dɪˈsɪʒən/', 'n决定'], ['explore', '/ɪkˈsplɔː/', 'v探讨，探究；考察，探索；探查，仔细检查'], ['explorer', '/ɛkˈsplɔːɹə(ɹ)/', 'n探险者，勘探者'], ['exploration', '/ˌɛkspləˈɹeɪʃən/', 'n勘探，勘察；研究，探究'], ['explode', '/ɪkˈspləʊd/', 'v爆炸，爆发，激增'], ['photo', '/ˈfəʊ.təʊ/', 'v/n拍照，照片'], ['notice', '/ˈnəʊtɪs/', 'v/n注意，察觉，通告，布告'], ['notification', '/ˌnəʊtɪfɪˈkeɪʃən/', 'n通知，通知书，布告，通告'], ['sound', '/saʊnd/', 'v/n听起来，声音'], ['voice', '/vɔɪs/', 'n声音（人的）'], ['noise', '/nɔɪz/', 'n噪音'], ['noisy', '/ˈnɔːɪzɪ/', 'a吵闹的，喧闹的'], ['behind', '/bəˈhaɪnd/', 'prep在...的后面'], ['hair', '/heː/', 'n头发'], ['style', '/staɪl/', 'v/n命名，风格，作风'], ['barber', '/ˈbɑː.bə/', 'v/n理发，理发师'], ['reply', '/ɹɪˈplaɪ/', 'v/n回答，回应，答复'], ['apply', '/əˈplaɪ/', 'v申请，应用，适用'], ['supply', '/səˈplaɪ/', 'v/n供应，提供，供给，生活必须品，日用品'], ['supplies', '/səˈplaɪz/', 'v/n供应，物资，贮备量'], ['wonder', '/ˈwʌndə/', 'v幻想，《奇迹男孩》，认为，思考'], ['wonderful', '/ˈwʌn.də.fl/', 'a极好的，美妙的'], ['wonderfully', '/wʌn.də(ɹ).fli/', 'ad极好地，惊人地，非常'], ['mile', '/maɪ̯l/', 'n英里'], ['smile', '/ˈsmaɪ.əl/', 'v/n微笑'], ['simile', '/ˈsɪməli/', 'n明喻（直白的比喻）'], ['bore', '/bɔː/', 'v/n使厌烦，钻孔'], ['bored', '/bɔːd/', 'a无聊的，厌倦的'], ['boredom', '/ˈbɔː.dəm/', 'n厌烦，无聊'], ['worry', '/ˈwɒɹi/', 'v/n使担心，担心，忧虑'], ['worried', '/ˈwʌɹid/', 'a担心的，发愁的'], ['soon', '/suːn/', 'ad很快，马上，不久'], ['moon', '/muːn/', 'n月亮'], ['noon', '/nuːn/', 'n中午'], ['noodle', '/nuːdl̩/', 'n面条（常用复数noodles）'], ['finding', '/ˈfaɪndɪŋ/', 'n结果，发现'], ['true', '/tɹuː/', 'a/ad真实的,正确的'], ['truth', '/tɹuːθ/', 'n真相'], ['truthful', '/ˈtɹuːθ.f(ə)l/', 'a诚实的,真实的,如实的'], ['English', '/ˈɪŋ.ɡlɪʃ/', 'a/n英语，英语的'], ['step', '/stɛp/', 'v/n跨步，踏，踩，做，进程，步骤，阶段'], ['surprise', '/səˈpɹaɪz/', 'v/n使吃惊，意外，惊喜'], ['surprised', '/səˈpɹaɪzd/', 'a意外的，惊讶的'], ['same', '/seɪm/', 'a/n相同的，同样的人/事物（前面必须有the）'], ['meeting', '/ˈmiːtɪŋ/', 'v/n见面，会晤，会议'], ['star', '/stɑː(ɹ)/', 'n明星,星星'], ['starry', '/ˈstɑː.ɹi/', 'a星光闪闪的,明亮的'], ['start', '/stɑːt/', 'v/n开始,着手,创办'], ['stark', '/stɑːk/', 'a荒凉的，朴实的，光秃秃的'], ['front', '/fɹʌnt/', 'a/v/n领导，主持，前面（的），前锋'], ['frontier', '/fɹʌnˈtɪə/', 'a/n边境（的），边疆的，国界，前沿'], ['induce', '/ɪnˈdjuːs/', 'v引诱，诱使，引起，导致，归纳出'], ['reduce', '/ɹɪˈdjuːs/', 'v减少，降低'], ['conduce', '/kənˈdjuːs/', 'v导致，有益，有贡献于'], ['product', '/ˈpɹɒd.əkt/', 'n产品，产物'], ['production', '/pɹəˈdʌkʃən/', 'n加工，生产，产量，制作，上映，上演'], ['introduce', '/ˌɪntɹəˈdjuːs/', 'v/n介绍，引见'], ['introduction', '/ˌɪntɹəˈdʌkʃən/', 'n介绍，引见'], ['glass', '/ɡlɑːs/', 'n玻璃（不可数），眼镜（眼镜）'], ['class', '/klas/', 'v/n把...归类，班级，阶级，等级，课程，课'], ['first', '/fɪrst/', 'a/ad/n第一（的）'], ['place', '/pleɪs/', 'v/n放置，归类，地方，位置，排名'], ['brain', '/bɹeɪn/', 'n大脑，智力，智慧'], ['brainstorm', '/ˈbɹeɪnstɔː(ɹ)m/', 'v/n集体讨论，集思广益，灵感，头脑风暴'], ['engine', '/end͡ʒən/', 'n发动机，引擎；机车，器械；工具，手段；驱动力，推动力'], ['engineer', '/ˌɛnd͡ʒɪˈnɪə/', 'n工程师，设计师'], ['name', '/neɪm/', 'v/n命名，名字'], ['nickname', '/ˈnɪkneɪm/', 'n外号，绰号'], ['bay', '/beɪ/', 'n海湾'], ['cay', '/keɪ/', 'n珊瑚礁'], ['day', '/deɪ/', 'n天，日子'], ['fay', '/feɪ/', 'n小仙女'], ['gay', '/ɡeɪ/', 'a/n同心恋（的）'], ['hay', '/heɪ/', 'n干草'], ['jay', '/dʒeɪ/', 'n松鸦，喋喋不休的人'], ['lay', '/leɪ/', 'v躺下，产卵'], ['may', '/meɪ/', 'v也许（+v原型）'], ['pay', '/peɪ/', 'v/n支付，账单'], ['ray', '/ɹeɪ/', 'n光线'], ['say', '/seɪ/', 'v说'], ['saying', '/ˈseɪɪŋ/', 'n谚语，格言，警句'], ['stay', '/steɪ/', 'v/n停留，逗留，维持，延缓'], ['way', '/weɪ/', 'n手段，方式，方法，道路'], ['would', '/wʊd/', 'v将，愿意（+v原型）'], ['course', '/kɔːs/', 'v/n奔流，快速流动，涌动，课程，过程，方针，疗程'], ['source', '/sɔːs/', 'v/n（找出……的）来源/出处；根源；源头，发源地'], ['resource', '/ɹɪˈsɔɹs/', 'n资源，出路，应付办法，个人素质'], ['press', '/pɹɛs/', 'v/n按压，逼迫，新闻，出版社，印刷机'], ['pressure', '[ˈpɹɛʃ.ə(ɹ)]', 'n压力，挤压，压强，紧张，催促'], ['depress', '/dɪˈpɹɛs/', 'v使抑郁，使沮丧；降低，抑制；使萧条，使不景气'], ['depressive', '/dɪˈpɹɛsɪv/', 'a抑郁的；压抑的'], ['depression', '/dɪˈpɹɛʃən/', 'n抑郁，沮丧；萧条（期），不景气；低气压'], ['compress', '/kəmˈpɹɛs/', 'v/n压紧/缩；浓缩；缩短，（止血）敷布，压布'], ['express', '/ɛk.ˈspɹɛs/', 'v/n表达，表现，快车，快递'], ['impress', '/ˈɪmpɹɛs/', 'v/n使钦佩，使留下深刻印象；使铭记；传送，印记'], ['impressive', '/ɪmˈpɹɛsɪv/', 'a给人印象深刻的，令人钦佩的'], ['impression', '/ɪmˈpɹɛʃən/', 'n印象，感想；影响，作用；印记'], ['sect', '/sɛkt/', 'n宗派'], ['section', '/ˈsɛkʃən/', 'v/n切开，切断，部分，部件，部门'], ['insect', '/ˈɪnsɛkt/', 'n昆虫'], ['collect', '/kəˈlɛkt/', 'v收集'], ['collection', '/kəˈlɛkʃən/', 'n收集'], ['collective', '/kəˈlɛktɪv/', 'a/n集体的，共有的，总体的，集体成员'], ['per', '/pɜː(ɹ)/', 'prep/ad每，每一'], ['perhaps', '/pəˈhæps/', 'ad也许，大概'], ['hap', '/hæp/', 'v/n偶然发生，机会，运气'], ['happen', '/ˈhæpən/', 'v发生，使遭遇，碰巧'], ['organizer', '/ˈɔɹɡənaɪzɚ/', 'n组织者，承办单位'], ['head', '/hɛd/', 'v/n朝某方向行进,头脑,智力,头'], ['headache', '/ˈhɛdeɪk/', 'n头疼，难题'], ['heading', '[ˈhɛɾ.ɪŋ]', 'n标题,题目,方向'], ['overhead', '/ˈəʊvəˌhɛd/', '在头顶上空，在空中'], ['next', '/nɛkst/', 'a接下来的，下一个的'], ['text', '/tɛkst/', 'n文本，正文，原文'], ['nudge', '/nʌdʒ/', 'v/n用肘轻触，轻推，碰；说服，鼓励'], ['drag', '/dɹæɡ/', 'v/n托，拽，累赘'], ['dragon', '/ˈdɹæɡən/', 'n龙'], ['dragonfly', '/ˈdɹæɡənˌflaɪ/', 'n蜻蜓'], ['butterfly', '/ˈbʌtə(ɹ)flaɪ/', 'n蝴蝶'], ['ache', '/eɪk/', 'v/n痛，疼痛，渴望'], ['achy', '/eɪ.ki/', 'a疼痛的'], ['headache', '/ˈhɛdeɪk/', 'n头疼，难题'], ['stomach', '/ˈstʌmək/', 'v/n忍受，胃，腹部'], ['stomachache', '/ˈstʌməkˌeɪk/', 'n胃疼，肚子痛'], ['pain', '/peɪn/', 'v/n（使）痛苦，（使）苦恼'], ['painful', '/ˈpeɪn.fəl/', 'a疼痛的，痛苦的'], ['breath', '/bɹɛθ/', 'n呼吸，气息'], ['breathe', '/bɹiːð/', 'v呼吸，呼出'], ['breathless', '/ˈbɹɛθləs/', 'a喘不过气来的；停止呼吸的'], ['breathtaking', '/ˈbɹɛθˌteɪ.kɪŋ/', 'a激动人心的，令人惊叹的；非常糟糕的，令人震惊的'], ['laugh', '/laːf/', 'v大笑，嘲笑'], ['laughter', '/ˈlɑːftə/', 'n笑声'], ['panic', '/ˈpænɪk/', 'a/v/n惊恐的，使惊慌/恐慌'], ['picnic', '/ˈpɪknɪk/', 'v/n野餐'], ['share', '/ʃɛə/', 'v/n分享,股份'], ['shared', '/ˈʃɛə(ɹ)d/', 'a/v分享,共享的'], ['each', '/iːt͡ʃ/', 'a每个的'], ['beach', '/biːt͡ʃ/', 'n海滩，海滨'], ['leach', '/liːtʃ/', 'v/n过滤（器）'], ['peach', '/piːt͡ʃ/', 'v/n告发，桃子'], ['reach', '/ɹiːt͡ʃ/', 'v达到，抵达，伸手，实现'], ['teach', '/tiːt͡ʃ/', 'v教'], ['teacher', '/ˈtiːt͡ʃə/', 'n老师'], ['search', '/sɜːt͡ʃ/', 'v/n搜索，搜寻'], ['research', '/ɹɪˈsɜːtʃ/', 'v/n研究，探讨，探索'], ['attention', '/əˈtɛn.ʃən/', 'n注意，注意力，照料'], ['nerve', '/nɛɾv/', 'n神经，勇气'], ['tough', '/tʌf/', 'a坚硬的，艰难的，严厉的，顽强的'], ['thought', '/θɔːt/', 'v/n思考，认为，想法'], ['through', '/θɹuː/', 'prep通过，穿过，遍及'], ['throughout', '/θɹuˈʌʊt/', 'prep/ad遍及，到处'], ['embrace', '/ɛmˈbɹeɪs/', 'v/n拥抱，欣然接受，包括，涉及，围绕'], ['embarrass', '/ɪmˈbæ.ɹəs/', 'v（使）尴尬，窘迫，使难堪，使为难'], ['relaxed', '/ɹɪˈlækst/', 'a放松的，轻松的（主语为人）'], ['kind', '/kaɪnd/', 'a善良的 n种类'], ['kindness', '/ˈkaɪndnəs/', 'n善良，友好，仁慈'], ['face', '/feɪs/', 'v/n面对，脸'], ['facial', '/ˈfeɪʃəl/', 'a/n面部的，美容'], ['change', '/tʃeɪndʒ/', 'v/n改变'], ['changeable', '/ˈt͡ʃeɪnd͡ʒəbəl/', 'a可改变的，变化无常的'], ['exchange', '/ɛksˈtʃeɪndʒ/', 'v/n交换，更换，兑换，交易，交易所'], ['challenge', '/ˈtʃæl.əndʒ/', 'v/n挑战（书），质疑，考验'], ['challenging', '/ˈtʃæləndʒɪŋ/', 'a有挑战性的'], ['fright', '/fɹʌit/', 'v/n惊骇，恐怖，惊吓，恐怖的经历'], ['frighten', '/ˈfɹaɪtn̩/', 'v使惊吓，使惊恐'], ['bright', '/bɹaɪt/', 'a/n明亮的,鲜艳的,聪明的,欢快的，有活力的,光明的，有希望的'], ['fight', '[fʌɪt]', 'v/n斗争，打斗，打架'], ['light', '/lʌɪt/', 'v/n点火，点燃，照亮，启迪，打火机，光线'], ['blight', '/blaɪt/', 'v/n使枯萎，使荒芜'], ['plight', '/plaɪt/', 'v/n保证，约定，困境，窘境'], ['might', '/maɪt/', 'v也许，可能'], ['delight', '/dəˈlaɪt/', 'v/n使高兴，乐事'], ['delighted', '/dɪˈlaɪtəd/', 'a高兴的'], ['night', '/naɪt/', 'a/n夜晚（的），夜间的'], ['knight', '/naɪt/', 'n骑士'], ['nightmare', '/ˈnaɪt.mɛə/', 'n噩梦，梦魇'], ['depend', '/dɪˈpɛnd/', 'v取决于，依赖，依靠，相信，指望'], ['dependable', '[dɪˈpɛndəbəɫ]', 'a可靠的，可信赖的'], ['calm', '/kam/', 'a镇静的'], ['palm', '/ˈpæm/', 'n手掌，棕榈树  v（篮球）持球犯规；用手挡（球）'], ['prepare', '/pɹɪˈpɛə/', 'v准备'], ['preparation', '/pɹɛpəˈɹeɪʃən/', 'n准备'], ['beginner', '/bɪˈɡɪnə/', 'n新手，初学者'], ['guess', '/ɡɛs/', 'v/n猜测，推测，认为'], ['diary', '/ˈdaɪəɹi/', 'n日记，专栏'], ['dairy', '/ˈdɛəɹi/', 'a/n奶制的，乳品（的）；乳品业的，奶牛']]
# """
